#ifndef _HTTPBASICCREDERTIALS_HPP_
#define _HTTPBASICCREDERTIALS_HPP_

#include "jhdefs.hpp"
#include "net/HTTPRequest.hpp"
#include <string>


NET_NAMESPACE_BEGIN

class CHTTPBasicCredentials
{
public:
	CHTTPBasicCredentials();
	CHTTPBasicCredentials(const std::string& username, const std::string& password);
	explicit CHTTPBasicCredentials(const CHTTPRequest& request);
	explicit CHTTPBasicCredentials(const std::string& authInfo);
	~CHTTPBasicCredentials();

	void setUsername(const std::string& username);
	const std::string& getUsername() const;

	void setPassword(const std::string& password);
	const std::string& getPassword() const;

	void authenticate(CHTTPRequest& request) const;
	void proxyAuthenticate(CHTTPRequest& request) const;

	static const std::string SCHEME;

protected:
	void parseAuthInfo(const std::string& authInfo);


private:
	CHTTPBasicCredentials(const CHTTPBasicCredentials&);
	CHTTPBasicCredentials& operator = (const CHTTPBasicCredentials&);

	std::string m_username;
	std::string m_password;
};


NET_NAMESPACE_END

#endif
